package com.zhku.laosiji.service.Impl;

import com.zhku.laosiji.dao.UserMapper;
import com.zhku.laosiji.pojo.User;
import com.zhku.laosiji.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/** 用户管理业务层
 * @author Jiayuan
 * @version 1.0
 * @description:
 * @time 9/5/2018 12:16 PM
 */

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;

    public int stopUser(int id){
        return  userMapper.stopUser(id);
    }

    public int startUser(int id){
        return userMapper.startUser(id);
    }

    public int insert(User user){
        return userMapper.insert(user);
    }

    public int deleteUserById(int id){
        return userMapper.deleteByPrimaryKey(id);
    }

    public List<User> selectUserByNameOrTel(String search){
        return userMapper.selectUserByNameOrTel(search);
    }

    public List<User> getUesrList(){
       return userMapper.queryUser();
    }

    @Override
    public User selectByPrimaryKey(Integer id) {
        User user = userMapper.selectByPrimaryKey(id);
        return user;
    }

    @Override
    public User selectByName(String name) {
        return userMapper.selectByUsername(name);
    }

    @Override
    public int insertUser(User user) {
        return userMapper.insert(user);
    }

    public int update(User record){
        return userMapper.updateByPrimaryKeySelective(record);
    }
}
